package com.yunti.springboot.commonenum;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.LinkedList;
import java.util.List;

@Getter
@AllArgsConstructor
public enum SemesterEnum {

    七年上(1,1,"七年上","七年级上学期"),
    七年下(2,1,"七年下","七年级下学期"),
    八年上(3,2,"八年上","八年级上学期"),
    八年下(4,2,"八年下","八年级下学期"),
    九年上(5,3,"九年上","九年级上学期"),
    九年下(6,3,"九年下","九年级下学期");

    /**
     * 编码
     */
    private Integer code;

    /**
     * 编码
     */
    private Integer year;

    /**
     * tuihuanKind编码
     */
    private String name;

    /**
     * 名称
     */
    private String message;

    /**
     * @param semester
     * @return
     */
    public static SemesterEnum getEnumBySemester(Integer semester) {
        SemesterEnum[] value = values();
        for (SemesterEnum e : value) {
            if (e.getCode().equals(semester)) {
                return e;
            }
        }
        return null;
    }
    public static List<Integer> getEnumByCode(Integer year) {
        List<Integer>list = new LinkedList<>();
        SemesterEnum[] value = values();
        for (SemesterEnum e : value) {
            if (e.getYear().equals(year)) {
                list.add(e.getCode());
            }
        }
        return list;
    }
}
